/*
 * ContasPorPeriodoParametersSelection.java
 *
 * Created on January 12, 2009, 1:07 PM
 */

package doghost.reports;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import org.jdesktop.application.Action;
import org.jdesktop.swingx.JXDatePicker;

/**
 *
 * @author  duo
 */
public class ContasPorPeriodoParametersSelection extends javax.swing.JDialog {

    protected Date dataInicial;
    protected Date dataFinal;
    protected boolean saveFired;
    protected SimpleDateFormat dateFormat;

    /** Creates new form ContasPorPeriodoParametersSelection */
    public ContasPorPeriodoParametersSelection(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        this.setDataInicial(new Date());
        this.setDataFinal(new Date());
        this.setDateFormat();
        initComponents();
        Locale BRAZIL = new Locale("pt_BR_", "pt", "BR");
    }

    /**
     * Get the value of dataInicial
     *
     * @return the value of dataInicial
     */
    public Date getDataInicial() {
        return dataInicial;
    }

    /**
     * Set the value of dataInicial
     *
     * @param dataInicial new value of dataInicial
     */
    public void setDataInicial(Date dataInicial) {
        this.dataInicial = dataInicial;
    }

    /**
     * Get the value of dateFormat
     *
     * @return the value of dateFormat
     */
    public SimpleDateFormat getDateFormat() {
        return dateFormat;
    }

    /**
     * Set the value of dateFormat
     *
     * @param dateFormat new value of dateFormat
     */
    public void setDateFormat() {
        this.dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    }

    /**
     * Get the value of dataFinal
     *
     * @return the value of dataFinal
     */
    public Date getDataFinal() {
        return dataFinal;
    }

    /**
     * Set the value of dataFinal
     *
     * @param dataFinal new value of dataFinal
     */
    public void setDataFinal(Date dataFinal) {
        this.dataFinal = dataFinal;
    }

    /**
     * Get the value of saveFired
     *
     * @return the value of saveFired
     */

    public boolean isSaveFired() {
        return saveFired;
    }

    /**
     * Set the value of saveFired
     *
     * @param saveFired new value of saveFired
     */
    public void setSaveFired(boolean saveFired) {
        this.saveFired = saveFired;
    }

    @Action
    public void saveParameters() {
        setSaveFired(true);
        setVisible(false);
    }

    @Action
    public void cancelParameters() {
        setSaveFired(false);
        setVisible(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingGroup = new org.jdesktop.beansbinding.BindingGroup();

        snOficialButtonGroup = new javax.swing.ButtonGroup();
        customFormattedDateConverter1 = new doghost.utils.CustomFormattedDateConverter();
        customFormattedDateValidator1 = new doghost.utils.CustomFormattedDateValidator();
        jXMonthView1 = new org.jdesktop.swingx.JXMonthView();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jXDatePickerDataInicial = new org.jdesktop.swingx.JXDatePicker();
        jXDatePickerDataFinal = new org.jdesktop.swingx.JXDatePicker();

        jXMonthView1.setDaysOfTheWeek(new String[] {"Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"});
        jXMonthView1.setFirstDayOfWeek(2);
        jXMonthView1.setName("jXMonthView1"); // NOI18N

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(doghost.DoghostApp.class).getContext().getResourceMap(ContasPorPeriodoParametersSelection.class);
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(doghost.DoghostApp.class).getContext().getActionMap(ContasPorPeriodoParametersSelection.class, this);
        jButton1.setAction(actionMap.get("saveParameters")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N

        jButton2.setAction(actionMap.get("cancelParameters")); // NOI18N
        jButton2.setName("jButton2"); // NOI18N

        jXDatePickerDataInicial.setFormats(new DateFormat[]{ new SimpleDateFormat("dd/MM/yyyy")});
        jXDatePickerDataInicial.setMonthView(jXMonthView1);
        jXDatePickerDataInicial.setName("jXDatePickerDataInicial"); // NOI18N

        org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${dataInicial}"), jXDatePickerDataInicial, org.jdesktop.beansbinding.BeanProperty.create("date"));
        bindingGroup.addBinding(binding);

        jXDatePickerDataFinal.setFormats(new DateFormat[]{ new SimpleDateFormat("dd/MM/yyyy")});
        jXDatePickerDataFinal.setName("jXDatePickerDataFinal"); // NOI18N

        binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, this, org.jdesktop.beansbinding.ELProperty.create("${dataFinal}"), jXDatePickerDataFinal, org.jdesktop.beansbinding.BeanProperty.create("date"));
        bindingGroup.addBinding(binding);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButton1)
                        .addGap(18, 18, 18)
                        .addComponent(jButton2))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel1)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addGap(8, 8, 8)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jXDatePickerDataFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jXDatePickerDataInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(151, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(35, 35, 35)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jXDatePickerDataInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jXDatePickerDataFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(66, 66, 66)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2))
                .addContainerGap(23, Short.MAX_VALUE))
        );

        bindingGroup.bind();

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                ContasPorPeriodoParametersSelection dialog = new ContasPorPeriodoParametersSelection(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private doghost.utils.CustomFormattedDateConverter customFormattedDateConverter1;
    private doghost.utils.CustomFormattedDateValidator customFormattedDateValidator1;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private org.jdesktop.swingx.JXDatePicker jXDatePickerDataFinal;
    private org.jdesktop.swingx.JXDatePicker jXDatePickerDataInicial;
    private org.jdesktop.swingx.JXMonthView jXMonthView1;
    private javax.swing.ButtonGroup snOficialButtonGroup;
    private org.jdesktop.beansbinding.BindingGroup bindingGroup;
    // End of variables declaration//GEN-END:variables

}
